package cn.chenyumeng.blog.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSenderImpl;
import org.springframework.stereotype.Service;

import java.util.Objects;

/**
 * @program: blog->EmailService
 * @description:
 * @author: cg
 * @create: 2020-10-28 10:02
 **/
@Service
public class EmailService {

    @Autowired
    private JavaMailSenderImpl javaMailSender;

    /**
     * 简单邮件测试
     */
    public void sendSimple(String to, String blog) {
        SimpleMailMessage message = new SimpleMailMessage();
        message.setSubject("Chenyumeng");
        message.setText("您的评论有被回复，请速查看！地址：" + blog);
        message.setTo(to);
        message.setFrom(Objects.requireNonNull(javaMailSender.getUsername()));
        javaMailSender.send(message);
    }
}
